<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
<style type="text/css">
    .money{width: 8em;}

</style>
    <link href="/Public/common.css" rel="stylesheet">
</head>
<body>
<table border="1" style="border-collapse:collapse;text-align:center;width: 100%">

    <tr>
        <th>用户ID</th>
        <th>用户姓名</th>

        <th>提取时间</th>
        <th>提取金额</th>
        <th>提取方式</th>
        <th>提取账号</th>
        <th>处理情况</th>
    </tr>
    <{foreach from=$data item=item}>
    <tr>
        <td><{$item['user_id']}></td>
        <td><{$agentKV[$item['user_id']]}></td>

        <td><{$item['create_time']}></td>
        <td><{$item['money']}></td>
        <td><{$payType[$item['type']]}></td>
        <td><{$item['bank_card_id']}></td>
        <td><{if $item['apply_status'] eq $done}>
                已处理
            <{else}>
                未处理
            <{/if}>
        </td>

    </tr>
    <{/foreach}>



    <script src="/Public/js/jquery-2.1.4.min.js"></script>
    <script>
        var doing=false;
        $('.pay').click(function(){

            var obj=$(this).prev();
            var agentID=obj.attr('agentId');
            var agent=obj.attr('agent');
            var money=obj.val();
            if(money+0<1){
                alert("结算金额未输入");
                return false;
            }

            var tips="确定结算吗？\n 代理:"+agent+" \r 编号:"+agentID+" \r 金额:"+money;
            if(!window.confirm(tips)){
                return false;
            }
            if(doing){
                alert("已有操作在处理，请勿重复提交");
                return;
            }

            doing=true;
            $.post("<{U('Game/agentPayDo')}>",{agentID:agentID,money:money},function(re){
                doing=false;
                if(re.status!=0){
                    alert(re.msg);
                    return;
                }else{
                    var unpay=$('#unpay_'+re.id);
                    var pay=$('#pay_'+re.id);
                    unpay.text(parseFloat(unpay.text()) - re.money);
                    pay.text(parseFloat(pay.text()) + re.money);
                    if(parseFloat(unpay.text())<=0){
                        pay.next().empty();
                    }else{}
                        pay.next().find('input').val(0);
                }

            },'JSON');

        });

    </script>
</table>
</body>
</html>